package com.sunchen.asc.application.rest;

import com.sunchen.asc.service.common.ResultResponse;
import com.sunchen.asc.service.item.api.TitleService;
import com.sunchen.asc.service.item.vo.TitleVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/title")
public class TitleRest {

    @DubboReference
    private TitleService titleService;

    @ApiOperation(value = "新增主题")
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    public ResultResponse createTitle(@RequestBody @ApiParam(name="事项vo",value="传入json格式",required=true) TitleVo titleVo){

        return titleService.createTitle(titleVo);
    }

    @ApiOperation(value = "编辑主题")
    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    public ResultResponse editTitle(@RequestBody @ApiParam(name="主题对象vo",value="传入json格式",required=true) TitleVo titleVo){

        return titleService.editTitle(titleVo);
    }

    @ApiOperation(value = "删除主题")
    @ApiImplicitParam(name="id",value = "主题id",dataType = "Long",required = true)
    @RequestMapping(value = "/delete",method = RequestMethod.GET)
    public ResultResponse deleteTitle(@RequestParam Long id){

        return titleService.deleteTitle(id);
    }

    @ApiOperation(value = "主题列表")
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public ResultResponse list(){

        return titleService.list();
    }

    @ApiOperation(value = "获取主题")
    @ApiImplicitParam(name="titleType",value = "主题类型",required = true)
    @RequestMapping(value = "/show/type",method = RequestMethod.GET)
    public ResultResponse showByType(@RequestParam Integer titleType){

        return titleService.showByType(titleType);
    }

}
